<?php
namespace app\common\model\tyyh;

class UserOpenid extends CUBase {

	public function create4phone($options) {
		$uid = User::factory()->create4phone($options['phone']);
		$data =['uid' => $uid, 'unionid' => $options['unionid'], 'miniprogramid' => '', 'miniprogramid2' => '', 'miniprogram_oxy' => ''];
		if($options['login_type'] == 'miniprogram') {
			$data['miniprogramid'] = $options['openid'];
		} else if($options['login_type'] == 'miniprogram2') {
			$data['miniprogramid2'] = $options['openid'];
		} else if($options['login_type'] == 'miniprogram_oxy') {
			$data['miniprogram_oxy'] = $options['openid'];
		}
		$this->save($data);
		return $this->id;
	}
}
